<template>
    <div class="field-control">
        <Editor class="exp-input" :name="name" :disabled="!enable" :params="paramFields" @input="expInput" :data="value" ref="editor"></Editor>
        <div class="field-message" v-show="!validate">{{message}}</div>
    </div>
</template>
<script>
import base from "./base";
import Editor from "@/components/conditionEditor/index";
import $ from "@/common";
export default {
  extends: base,
  computed: {
    paramFields() {
      if (this.$parentRule) {
        return this.$parentRule.getExecModel().fields;
      } else {
        return [];
      }
    }
  },
  created() {
    this.$parentRule = $.getParent(this, "actionRule", true);
  },
  methods: {
    expInput(v) {
      this.valueInput(HTMLDecode(v));
    }
  },
  components: {
    Editor
  }
};
function HTMLDecode(text) {
  var temp = document.createElement("div");
  temp.innerHTML = text;
  var output = temp.innerText || temp.textContent;
  temp = null;
  return output;
}
</script>
<style lang="less">
.exp-input {
  min-height: 90px;
  .exp-editor .editor-content {
    height: auto;
  }
  .code-editor {
    min-height: 200px;
  }
}
</style>
